package com.ylfstu.set_;

import java.util.HashMap;
@SuppressWarnings({"all"})
public class HashMapSource02 {
    public static void main(String[] args) {
        HashMap hashMap = new HashMap();
        for(int i = 1; i <= 12; i++) {
            hashMap.put(new A(i), "hello");
        }
//        hashMap.put("aaa", "bbb");
        System.out.println("hashMap=" + hashMap);
    }
}

class A{
    private int num;
    public A(int num) {
        this.num = num;
    }
    //所有的 A 对象的 hashCode 都是 100
    @Override
    public int hashCode() {
        return 100;
    }
    @Override
    public String toString() {
        return "\nA{" +
                "num=" + num +
                '}';
    }
}